{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/ai2-jedi/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\n",
      "  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')\n",
      "Using Theano backend.\n",
      "Using gpu device 0: GeForce GTX 980 Ti (CNMeM is disabled, cuDNN Mixed dnn version. The header is from one version, but we link with a different version (4007, 5005))\n"
     ]
    }
   ],
   "source": [
    "from IPython.display import clear_output\n",
    "import random\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import math\n",
    "import time\n",
    "import copy\n",
    "from grid_world_v2 import GridWorld\n",
    "from replay_memory import ReplayMemory\n",
    "\n",
    "from keras.models import Sequential\n",
    "from keras.layers.core import Dense, Dropout, Activation\n",
    "from keras.optimizers import RMSprop\n",
    "from keras.optimizers import Adam\n",
    "from keras.models import model_from_json\n",
    "from keras.callbacks import Callback\n",
    "from random import shuffle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class Tester(object):\n",
    "    def __init__(self, env, network, weights):\n",
    "        \n",
    "        self.env = env\n",
    "        if network == None:\n",
    "            network = self.createNetwork()\n",
    "        self.network = self.loadNetwork(network)\n",
    "        self.loadedModel = self.loadWeights(weights, self.network)\n",
    "        self.cust_episode = None\n",
    "        self.Naive_Game_Histories = []\n",
    "        self.Model_Game_Histories = []\n",
    "        \n",
    "    def loadNetwork(self,netowrk_name):\n",
    "        json_file = open('models/' + str(netowrk_name), 'r')\n",
    "        loaded_model_json = json_file.read()\n",
    "        json_file.close()\n",
    "        loaded_model = model_from_json(loaded_model_json)\n",
    "        return loaded_model\n",
    "        \n",
    "    def loadWeights(self,weights_name,loadedModel):\n",
    "        loadedModel.load_weights('weights/' + str(weights_name))\n",
    "        return loadedModel\n",
    "    \n",
    "    def createNetwork(self):\n",
    "        model = Sequential()\n",
    "        model.add(Dense(256, init='lecun_uniform', input_shape=(self.env.observation_shape,)))\n",
    "        model.add(Activation('relu'))\n",
    "        model.add(Dropout(0.2))\n",
    "        model.add(Dense(256, init='lecun_uniform'))\n",
    "        model.add(Activation('relu'))\n",
    "        model.add(Dropout(0.2))\n",
    "        model.add(Dense(self.env.num_actions, init='lecun_uniform'))\n",
    "        model.add(Activation('linear')) \n",
    "        rms = RMSprop()\n",
    "        model.compile(loss=\"mse\", optimizer = rms)\n",
    "        \n",
    "        model_json = model.to_json()\n",
    "        with open('models/model_' + str(self.env.grid_size) + 'x' + str(self.env.grid_size) + '.json', \"w\") as json_file:\n",
    "            json_file.write(model_json)\n",
    "            \n",
    "        return 'model_' + str(self.env.grid_size) + 'x' + str(self.env.grid_size) + '.json'\n",
    "            \n",
    "    def loopPolicy(self, games, max_test_len):\n",
    "        naive_moves, model_moves,naive_reward, model_reward = 0, 0, 0, 0\n",
    "        for i in range(games):\n",
    "            print 'Game: ', i\n",
    "            self.env.reset()\n",
    "            self.generateDemandEpisode(max_test_len + 1)\n",
    "        \n",
    "            #print 'Naive:'\n",
    "            naive_moves = naive_moves + self.runEpisodeFixedCustomer('Naive',1)\n",
    "            #naive_reward = naive_reward + self.runEpisodeFixedTime('Naive',1)\n",
    "            \n",
    "            #print 'Model:'\n",
    "            model_moves = model_moves + self.runEpisodeFixedCustomer(self.loadedModel,0)\n",
    "            #model_reward = model_reward + self.runEpisodeFixedTime(self.loadedModel,0)\n",
    "            \n",
    "            clear_output(wait=True)\n",
    "        naive_avg_moves = naive_moves/float(games)\n",
    "        model_avg_moves = model_moves/float(games)\n",
    "        \n",
    "        #naive_avg_reward = naive_reward/float(games)\n",
    "        #model_avg_reward = model_reward/float(games)\n",
    "        \n",
    "        print 'Naive avg moves: ', naive_avg_moves\n",
    "        print 'Model avg moves: ', model_avg_moves\n",
    "        #print 'Naive avg reward: ', naive_avg_reward\n",
    "        #print 'Model avg reward: ', model_avg_reward\n",
    "        return (naive_avg_moves, model_avg_moves)\n",
    "        \n",
    "    def runEpisodeFixedCustomer(self, model, epsilon):\n",
    "        terminal = False\n",
    "        env_copy = copy.deepcopy(self.env)\n",
    "        env_copy.reset(cust_popup_episode = self.cust_episode, cars_list = self.env.cars_list)\n",
    "        while(not terminal and env_copy.t < len(self.cust_episode) - 1):\n",
    "            #env_copy.print_grid()\n",
    "            \n",
    "            #Bookeeping\n",
    "            curr_history = {}\n",
    "            curr_history['t'] = env_copy.t\n",
    "            curr_history['curr_state'] = (env_copy.cars_grid.copy(), env_copy.cust_grid.copy())\n",
    "            \n",
    "            all_agents_step = env_copy.stepAll(model,epsilon)\n",
    "            \n",
    "            #More Bookeeping\n",
    "            curr_history['actions'] = all_agents_step\n",
    "            curr_history['next_state'] = (env_copy.cars_grid.copy(), env_copy.cust_grid.copy())\n",
    "            env_copy.history.append(curr_history)  \n",
    "                    \n",
    "            terminal = env_copy.isTerminal()\n",
    "            env_copy.t += 1\n",
    "            \n",
    "        if model == 'Naive':\n",
    "            self.Naive_Game_Histories.append(env_copy.history)\n",
    "        else: \n",
    "            self.Model_Game_Histories.append(env_copy.history)\n",
    "            \n",
    "        return env_copy.t\n",
    "    \n",
    "    def runEpisodeFixedTime(self, model, epsilon):\n",
    "        env_copy = copy.deepcopy(self.env)\n",
    "        env_copy.reset(cust_popup_episode = self.cust_episode, cars_list = self.env.cars_list)\n",
    "        episode_reward = 0\n",
    "        while(env_copy.t < len(self.cust_episode) - 1):\n",
    "            #env_copy.print_grid()\n",
    "            \n",
    "            #Bookeeping\n",
    "            curr_history = {}\n",
    "            curr_history['t'] = env_copy.t\n",
    "            curr_history['curr_state'] = (env_copy.cars_grid.copy(), env_copy.cust_grid.copy())\n",
    "            \n",
    "            all_agents_step = env_copy.stepAll(model,epsilon)\n",
    "            \n",
    "            #More Bookeeping\n",
    "            curr_history['actions'] = all_agents_step\n",
    "            curr_history['next_state'] = (env_copy.cars_grid.copy(), env_copy.cust_grid.copy())\n",
    "            env_copy.history.append(curr_history)  \n",
    "            \n",
    "            for mem in all_agents_step:\n",
    "                if mem['event'] == 'pickup':\n",
    "                    episode_reward = episode_reward + mem['reward']\n",
    "            env_copy.t += 1\n",
    "            \n",
    "        if model == 'Naive':\n",
    "            self.Naive_Game_Histories.append(env_copy.history)\n",
    "        else: \n",
    "            self.Model_Game_Histories.append(env_copy.history)\n",
    "            \n",
    "        return episode_reward\n",
    "    \n",
    "    def generateDemandEpisode(self, timesteps):\n",
    "        customer_episodes = []\n",
    "        for t in range(timesteps):\n",
    "            size = self.env.grid_size\n",
    "            cust_popup = np.zeros((size, size))\n",
    "            for i in range(size):\n",
    "                for j in range(size):\n",
    "                    if (random.random() < self.env.demand_init_prob[i, j]):\n",
    "                        random_waittime = np.random.randint(self.env.minWaitTime, self.env.maxWaitTime+1)\n",
    "                        cust_popup[i, j] = random_waittime\n",
    "            customer_episodes.append(cust_popup)\n",
    "        self.cust_episode = customer_episodes\n",
    "        \n",
    "    def print_history(self, history):\n",
    "        size = self.env.grid_size\n",
    "        action_options = {0: \"stay\", 1: \"left\", 2: \"up\", 3: \"right\", 4: \"down\"}\n",
    "        for hist in history:\n",
    "            cars_grid = hist[\"curr_state\"][0]\n",
    "            cust_grid = hist[\"curr_state\"][1]\n",
    "            car_events = hist[\"actions\"]\n",
    "            narrations = []\n",
    "            \n",
    "            print \"==================================\"\n",
    "            print \"At t = {0}\".format(hist[\"t\"])\n",
    "            print \" \"+ \"------\" * (size - 1)\n",
    "            state_to_print = np.zeros((size, size), dtype='<U2')\n",
    "            state_to_print[state_to_print == ''] = '  '\n",
    "            # customers\n",
    "            state_to_print[cust_grid > 0] = 'De'\n",
    "            # obstacles\n",
    "            state_to_print[self.env.obstacle_grid > 0] = '@@'\n",
    "            # cars\n",
    "            for car in self.env.cars_list:\n",
    "                state_to_print[(cars_grid) == car.carID] = 'C{0}'.format(car.carID)\n",
    "            state_to_print[(cust_grid > 0) & (cars_grid > 0)] = 'CD'\n",
    "            \n",
    "            for car_event in car_events:\n",
    "                narrations.append(\"C{0} chose {1}, {2} -> {3}. And its event type is {4}\".format(\n",
    "                        car_event['carID'], action_options[car_event['action']],\n",
    "                        car_event['original_location'], car_event['new_location'], car_event['event']))\n",
    "            print '| ' + '\\n| '.join([' . '.join(i) + ' |' for i in state_to_print])\n",
    "            print \" \"  + \"------\" * (size - 1)  \n",
    "            for n in narrations:\n",
    "                print n\n",
    "                \n",
    "        cars_grid = hist[\"next_state\"][0]\n",
    "        cust_grid = hist[\"next_state\"][1]\n",
    "        print \"==================================\"\n",
    "        print \"At final\".format(hist[\"t\"])\n",
    "        print \" \"+ \"------\" * (size - 1)\n",
    "        state_to_print = np.zeros((size, size), dtype='<U2')\n",
    "        state_to_print[state_to_print == ''] = '  '\n",
    "        # customers\n",
    "        state_to_print[cust_grid > 0] = 'De'\n",
    "        # obstacles\n",
    "        state_to_print[self.env.obstacle_grid > 0] = '@@'\n",
    "        # cars\n",
    "        for car in self.env.cars_list:\n",
    "            state_to_print[(cars_grid) == car.carID] = 'C{0}'.format(car.carID)\n",
    "        state_to_print[(cust_grid > 0) & (cars_grid > 0)] = 'CD'\n",
    "        print '| ' + '\\n| '.join([' . '.join(i) + ' |' for i in state_to_print])\n",
    "        print \" \"  + \"------\" * (size - 1)  \n",
    "        \n",
    "    def plot(self,games,max_game_length,saved_weights_freq,max_epochs, weights_name):\n",
    "        epoch = []\n",
    "        naive_list = []\n",
    "        model_list = []\n",
    "        for i in range(1, (max_epochs/saved_weights_freq) + 1 ):\n",
    "            index = i * saved_weights_freq\n",
    "            file_name = weights_name + '_' + str(index) + '.h5'\n",
    "            self.loadedModel = self.loadWeights(file_name , self.network)\n",
    "            print 'Loaded: ', file_name\n",
    "            epoch.append(index)\n",
    "            naive_avg_moves, model_avg_moves = tester.loopPolicy(games, max_game_length)\n",
    "            naive_list.append(naive_avg_moves)\n",
    "            model_list.append(model_avg_moves)\n",
    "        \n",
    "        #return epoch, naive_list, model_list\n",
    "        plt.plot(epoch,naive_list,epoch,model_list )\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test Single Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "obstacle_grid = np.array([[0,0,1,1,1,0,0],\n",
    "              [0,0,0,1,0,0,0],\n",
    "              [0,0,1,1,1,0,0],\n",
    "              [0,0,0,0,0,0,0],\n",
    "              [0,0,1,1,1,0,0],\n",
    "              [0,0,0,1,0,0,0],\n",
    "              [0,0,1,1,1,0,0]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "env = GridWorld(num_cars = 2, grid_size = 7, terminal_reward = 5,\n",
    "                customer_rate = 0.04, demand_limit = 1, cust_wait_time = 10, obstacle_grid = obstacle_grid)\n",
    "tester = Tester(env, 'model_7x7_4layer.json', 'Gridworld_7x7_4Layer_NoTD_300.h5')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Naive avg moves:  30.948\n",
      "Model avg moves:  20.064\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(30.948, 20.064)"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tester.loopPolicy(500, 50)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot Performance Over Epochs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Naive avg moves:  31.956\n",
      "Model avg moves:  20.08\n"
     ]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AMz+3ZoWY5zrgy8FyTQ3bfqYqP7Wdpz+jbd\nRfJu00gn4CVt+8ysL94nlKWc/fWYCu1bFlqUEtvPzNLMbBXeuUKvOec+IIbbT98K2TCjnXOXATcA\nPzCzq/ECP1yq7aFOtfacfgLef/lcT5OYWXvgWeDeUA83pV6PEdqXMtvPORd0zg3F+8Q13MwGEsPt\nF69w3wX0CbveK7QsqTnnPg9d7gNewPtYVGZmOeAd/w/s9a/CmDhbe3YBvcPWS8pt6pzb50KDmMD/\ncPKjbdK1z8wy8IJvjnPuxdDilNl+kdqXStuvlnOuAigBxhHD7RevcP8A6G9meWbWCpgMvBSnx2oW\nZpYV6kVgZu2AMcBavHbNCK12F/BixD+QuE45QY2zt+clYLKZtTKzC4D+wPLmKrIJzjgBL+y28BPw\nkrF9jwEfOeceCluWStvvjPalyvYzs661Q0pm1ha4Dm+/Quy2Xxz3BI/D28P9CfBTv/dMx6A9F+Ad\n9bMKL9R/GlreBVgcausioLPftTagTXOB3UAlsB34BpB9tvYAP8PbS78BGON3/Y1s3xPAmtC2fAFv\njDPp2geMBmrCXpMfhv7nzvp6TJH2pcr2GxRqU2moPf8cWh6z7aeTmEREUpB2qIqIpCCFu4hIClK4\ni4ikIIW7iEgKUriLiKQghbuISApSuIuIpCCFu4hICvr/45VUHbgXqqEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f2e49921350>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "tester.plot(500,50,20,300,'Gridworld_7x7_4Layer_NoTD')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Show Game History"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==================================\n",
      "At t = 0\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose right, (4, 6) -> (4, 6). And its event type is hit_wall\n",
      "C2 chose up, (2, 1) -> (1, 1). And its event type is move\n",
      "==================================\n",
      "At t = 1\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 6) -> (4, 5). And its event type is move\n",
      "C2 chose down, (1, 1) -> (2, 1). And its event type is move\n",
      "==================================\n",
      "At t = 2\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "| De .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "==================================\n",
      "At t = 3\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    .    .    .    .    |\n",
      "| De .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose left, (3, 1) -> (3, 0). And its event type is move\n",
      "==================================\n",
      "At t = 4\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "| C2 .    .    .    .    .    .    |\n",
      "| De .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose down, (3, 0) -> (4, 0). And its event type is pickup\n",
      "==================================\n",
      "At t = 5\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "| C2 .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (4, 5) -> (5, 5). And its event type is move\n",
      "C2 chose left, (4, 0) -> (4, 0). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 6\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . De .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "| C2 .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (5, 5) -> (4, 5). And its event type is move\n",
      "C2 chose up, (4, 0) -> (3, 0). And its event type is move\n",
      "==================================\n",
      "At t = 7\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . De .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "| C2 .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose right, (3, 0) -> (3, 1). And its event type is move\n",
      "==================================\n",
      "At t = 8\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . De .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "==================================\n",
      "At t = 9\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . De .    . @@ .    .    .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose up, (2, 1) -> (1, 1). And its event type is pickup\n",
      "==================================\n",
      "At t = 10\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose left, (1, 1) -> (1, 0). And its event type is move\n",
      "==================================\n",
      "At t = 11\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "| C2 .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose down, (1, 0) -> (2, 0). And its event type is pickup\n",
      "==================================\n",
      "At t = 12\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| C2 .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose stay, (2, 0) -> (2, 0). And its event type is stay\n",
      "==================================\n",
      "At t = 13\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| CD .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 5) -> (4, 5). And its event type is collision\n",
      "C2 chose stay, (2, 0) -> (2, 0). And its event type is pickup\n",
      "==================================\n",
      "At t = 14\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| C2 .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose right, (4, 5) -> (4, 6). And its event type is move\n",
      "C2 chose right, (2, 0) -> (2, 1). And its event type is move\n",
      "==================================\n",
      "At t = 15\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose right, (4, 6) -> (4, 6). And its event type is hit_wall\n",
      "C2 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "==================================\n",
      "At t = 16\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (4, 6) -> (4, 5). And its event type is move\n",
      "C2 chose down, (3, 1) -> (4, 1). And its event type is move\n",
      "==================================\n",
      "At t = 17\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    . C2 . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose stay, (4, 1) -> (4, 1). And its event type is stay\n",
      "==================================\n",
      "At t = 18\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "| De .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 5) -> (3, 4). And its event type is move\n",
      "C2 chose left, (4, 1) -> (4, 0). And its event type is move\n",
      "==================================\n",
      "At t = 19\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    . C1 .    .    |\n",
      "| C2 .    . @@ . @@ . @@ .    .    |\n",
      "| De .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 4) -> (3, 3). And its event type is move\n",
      "C2 chose down, (4, 0) -> (5, 0). And its event type is pickup\n",
      "==================================\n",
      "At final\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . C1 .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "| C2 .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n"
     ]
    }
   ],
   "source": [
    "tester.print_history(tester.Naive_Game_Histories[10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==================================\n",
      "At t = 0\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    . C2 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "C2 chose down, (1, 5) -> (2, 5). And its event type is move\n",
      "==================================\n",
      "At t = 1\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C2 .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . De |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (0, 6) -> (1, 6). And its event type is move\n",
      "C2 chose right, (2, 5) -> (2, 6). And its event type is move\n",
      "==================================\n",
      "At t = 2\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . C1 |\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . De |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (1, 6) -> (1, 6). And its event type is collision\n",
      "C2 chose down, (2, 6) -> (3, 6). And its event type is move\n",
      "==================================\n",
      "At t = 3\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . C1 |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    . C2 |\n",
      "|    .    . @@ . @@ . @@ .    . De |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (1, 6) -> (2, 6). And its event type is move\n",
      "C2 chose down, (3, 6) -> (4, 6). And its event type is pickup\n",
      "==================================\n",
      "At t = 4\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (2, 6) -> (3, 6). And its event type is move\n",
      "C2 chose left, (4, 6) -> (4, 5). And its event type is move\n",
      "==================================\n",
      "At t = 5\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    . C1 |\n",
      "|    .    . @@ . @@ . @@ . C2 .    |\n",
      "|    .    .    . @@ .    .    . De |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 6) -> (4, 6). And its event type is move\n",
      "C2 chose right, (4, 5) -> (4, 5). And its event type is collision\n",
      "==================================\n",
      "At t = 6\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C2 . C1 |\n",
      "|    .    .    . @@ .    .    . De |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (4, 6) -> (5, 6). And its event type is pickup\n",
      "C2 chose right, (4, 5) -> (4, 6). And its event type is move\n",
      "==================================\n",
      "At t = 7\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    . C1 |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (5, 6) -> (6, 6). And its event type is move\n",
      "C2 chose left, (4, 6) -> (4, 5). And its event type is move\n",
      "==================================\n",
      "At t = 8\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C2 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    . C1 |\n",
      " ------------------------------------\n",
      "C1 chose up, (6, 6) -> (5, 6). And its event type is move\n",
      "C2 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "==================================\n",
      "At t = 9\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C2 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . C1 |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (5, 6) -> (4, 6). And its event type is move\n",
      "C2 chose left, (3, 5) -> (3, 4). And its event type is move\n",
      "==================================\n",
      "At t = 10\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    . C2 .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 6) -> (3, 6). And its event type is move\n",
      "C2 chose left, (3, 4) -> (3, 3). And its event type is move\n",
      "==================================\n",
      "At t = 11\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . C2 .    .    . C1 |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 6) -> (4, 6). And its event type is move\n",
      "C2 chose left, (3, 3) -> (3, 2). And its event type is move\n",
      "==================================\n",
      "At t = 12\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    . C2 .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C1 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 6) -> (3, 6). And its event type is move\n",
      "C2 chose left, (3, 2) -> (3, 1). And its event type is move\n",
      "==================================\n",
      "At t = 13\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    .    .    .    . C1 |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 6) -> (3, 5). And its event type is move\n",
      "C2 chose down, (3, 1) -> (4, 1). And its event type is move\n",
      "==================================\n",
      "At t = 14\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose down, (4, 1) -> (5, 1). And its event type is move\n",
      "==================================\n",
      "At t = 15\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    . C2 .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose down, (5, 1) -> (6, 1). And its event type is move\n",
      "==================================\n",
      "At t = 16\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "| De . C2 . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose up, (6, 1) -> (5, 1). And its event type is move\n",
      "==================================\n",
      "At t = 17\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    . De .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    . C2 .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose up, (5, 1) -> (4, 1). And its event type is move\n",
      "==================================\n",
      "At t = 18\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    . De . C1 .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 5) -> (3, 4). And its event type is pickup\n",
      "C2 chose up, (4, 1) -> (3, 1). And its event type is move\n",
      "==================================\n",
      "At t = 19\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    .    . C1 .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose right, (3, 4) -> (3, 5). And its event type is move\n",
      "C2 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "==================================\n",
      "At t = 20\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    . De . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 5) -> (3, 4). And its event type is pickup\n",
      "C2 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "==================================\n",
      "At t = 21\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 .    .    . C1 .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose right, (3, 4) -> (3, 5). And its event type is move\n",
      "C2 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "==================================\n",
      "At t = 22\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    . De . @@ .    .    .    |\n",
      "|    . C2 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose up, (2, 1) -> (1, 1). And its event type is move\n",
      "==================================\n",
      "At t = 23\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C2 . De . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose right, (1, 1) -> (1, 2). And its event type is pickup\n",
      "==================================\n",
      "At final\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    . C2 . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . De .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n"
     ]
    }
   ],
   "source": [
    "tester.print_history(tester.Model_Game_Histories[4])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Cluster Situations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[[ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  2.  0.  0.  0.  0.  0.]\n",
      "  [ 1.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]]\n",
      "\n",
      " [[ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]\n",
      "  [ 0.  0.  0.  0.  0.  0.  0.]]]\n",
      "[[ 0.  0.  0.  0.  0.  0.  0.  0.  2.  0.  0.  0.  0.  0.  1.  0.  0.  0.\n",
      "   0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.\n",
      "   0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.\n",
      "   0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.\n",
      "   0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.\n",
      "   0.  0.  0.  0.  0.  0.  0.  0.]]\n"
     ]
    }
   ],
   "source": [
    "a = np.array(tester.Model_Game_Histories[2][0]['curr_state'])\n",
    "b = a.reshape(1,tester.env.observation_shape/2)\n",
    "print a\n",
    "print b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "500\n"
     ]
    }
   ],
   "source": [
    "starting_states = []\n",
    "for game in tester.Model_Game_Histories:\n",
    "    state = np.array(game[0]['curr_state'])\n",
    "    starting_states.append(state.reshape(1,tester.env.observation_shape/2)[0])\n",
    "print len(starting_states)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.cluster import KMeans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[  0.   0.   0.   0.   0.   0.   2.   0.   0.   0.   0.   0.   0.   0.   0.\n",
      "   0.   0.   0.   0.   1.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.\n",
      "   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.\n",
      "   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.  10.   0.   0.   0.\n",
      "   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.\n",
      "   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.\n",
      "   0.   0.   0.   0.   0.   0.   0.   0.]\n"
     ]
    }
   ],
   "source": [
    "print starting_states[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "kmeans = KMeans(n_clusters=4, random_state=0).fit(np.array(starting_states))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,\n",
       "       0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,\n",
       "       0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3, 0, 0, 1, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int32)"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "kmeans.labels_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[9, 36, 58, 95, 178, 202, 296, 361, 416, 478]\n"
     ]
    }
   ],
   "source": [
    "indices = [i for i, x in enumerate(kmeans.labels_) if x == 3]\n",
    "print indices"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==================================\n",
      "At t = 0\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ . De .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 . C2 |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (2, 5) -> (1, 5). And its event type is move\n",
      "C2 chose up, (2, 6) -> (1, 6). And its event type is move\n",
      "==================================\n",
      "At t = 1\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ . De .    |\n",
      "|    .    .    . @@ .    . C1 . C2 |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (1, 5) -> (0, 5). And its event type is pickup\n",
      "C2 chose up, (1, 6) -> (0, 6). And its event type is move\n",
      "==================================\n",
      "At t = 2\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ . C1 . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (0, 5) -> (1, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 3\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (1, 5) -> (2, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 4\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (2, 5) -> (3, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 5\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 6\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 7\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 8\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 9\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 10\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 11\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 12\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . De .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C1 .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 13\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . De .    . C1 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 5) -> (3, 4). And its event type is move\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 14\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . De . C1 .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 4) -> (3, 3). And its event type is pickup\n",
      "C2 chose up, (0, 6) -> (0, 6). And its event type is hit_wall\n",
      "==================================\n",
      "At t = 15\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . C1 .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 3) -> (3, 2). And its event type is move\n",
      "C2 chose down, (0, 6) -> (1, 6). And its event type is move\n",
      "==================================\n",
      "At t = 16\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . C2 |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    . C1 .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (3, 2) -> (3, 1). And its event type is move\n",
      "C2 chose down, (1, 6) -> (2, 6). And its event type is move\n",
      "==================================\n",
      "At t = 17\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . De |\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    . C1 .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "C2 chose up, (2, 6) -> (1, 6). And its event type is pickup\n",
      "==================================\n",
      "At t = 18\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . C2 |\n",
      "|    . C1 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "C2 chose down, (1, 6) -> (2, 6). And its event type is move\n",
      "==================================\n",
      "At t = 19\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    . C1 .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "C2 chose down, (2, 6) -> (3, 6). And its event type is move\n",
      "==================================\n",
      "At t = 20\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . De |\n",
      "|    . C1 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    . C2 |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "C2 chose up, (3, 6) -> (2, 6). And its event type is move\n",
      "==================================\n",
      "At t = 21\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . De |\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    . C1 .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "C2 chose up, (2, 6) -> (1, 6). And its event type is pickup\n",
      "==================================\n",
      "At t = 22\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    . C2 |\n",
      "|    . C1 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "C2 chose down, (1, 6) -> (2, 6). And its event type is move\n",
      "==================================\n",
      "At t = 23\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    . C2 |\n",
      "|    . C1 .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "C2 chose down, (2, 6) -> (3, 6). And its event type is move\n",
      "==================================\n",
      "At t = 24\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    . C1 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    . C2 |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "C2 chose left, (3, 6) -> (3, 5). And its event type is move\n",
      "==================================\n",
      "At t = 25\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C1 .    .    .    . C2 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose up, (3, 1) -> (2, 1). And its event type is move\n",
      "C2 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "==================================\n",
      "At t = 26\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    . C1 . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C2 .    |\n",
      "| De .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (2, 1) -> (3, 1). And its event type is move\n",
      "C2 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "==================================\n",
      "At t = 27\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    . C1 .    .    .    . C2 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "| De .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (3, 1) -> (4, 1). And its event type is move\n",
      "C2 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "==================================\n",
      "At t = 28\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    . C1 . @@ . @@ . @@ . C2 .    |\n",
      "| De .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose down, (4, 1) -> (5, 1). And its event type is move\n",
      "C2 chose up, (4, 5) -> (3, 5). And its event type is move\n",
      "==================================\n",
      "At t = 29\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    . C2 .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "| De . C1 .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n",
      "C1 chose left, (5, 1) -> (5, 0). And its event type is pickup\n",
      "C2 chose down, (3, 5) -> (4, 5). And its event type is move\n",
      "==================================\n",
      "At final\n",
      " ------------------------------------\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    . @@ .    .    .    |\n",
      "|    .    . @@ . @@ . @@ .    .    |\n",
      "|    .    .    .    .    .    .    |\n",
      "|    .    . @@ . @@ . @@ . C2 .    |\n",
      "| C1 .    .    . @@ .    .    .    |\n",
      "| De .    . @@ . @@ . @@ .    .    |\n",
      " ------------------------------------\n"
     ]
    }
   ],
   "source": [
    "tester.print_history(tester.Model_Game_Histories[202])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
